<template>
  <div>
    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
      <div class="widget am-cf">
        <div class="widget-head am-cf">
          <div class="widget-title am-fl">绑定学员</div>
        </div>
        <div class="widget-body  am-fr">
          <div class="am-u-sm-12 am-form ">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                <div class="am-form-group">
                    <el-input v-model="query.phoneNo" size="small"   placeholder="请输入账号（登录手机号）"></el-input>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3 am-u-end">
              <div class="am-form-group">
                <button type="button" class="am-btn am-btn-default am-btn-success"
                        @click="handsearch" ><span class="am-icon-search"></span>查询
                </button>
              </div>
            </div>
          </div>
          <div class="am-u-sm-12">
            <el-table
              :data="tableData"
              border
              stripe
              style="min-width: 100%">
              <el-table-column
                prop="phoneNo"
                label="账号（登陆手机号）"
                min-width="100">
              </el-table-column>
              <el-table-column
                label="已绑学员"
                min-width="100">
                <template scope="scope">
                    <el-button size="small" @click="handleSee(scope.row.userId)">查看</el-button>
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="操作"
                min-width="100">
                <template scope="scope">
                    <div>
                       <!-- <el-button @click="handleDelete(scope.row.adId)">删除</el-button> -->
                       <el-button size="small" @click="$router.push('/main/online/editorBingStudent?userId='+ scope.row.userId )">编辑</el-button>
                    </div>
                </template>
              </el-table-column>
            </el-table>
          </div>  
        </div>
        <div class="am-u-lg-12 am-cf">
          <div class="am-fr">
            <pagination v-bind:total="total" v-bind:pageNo="pageNo" v-bind:pageSize="pageSize"
                        @paging="loadTableData"/>
          </div>
        </div>
        <bing-student-show @completed="loadTableData" ref="bingStudentShow"></bing-student-show>
      </div>
    </div>
  </div>
</template>
<script>
  import io from '../../lib/io'
  import Pagination from '../base/Pagination.vue'
  import BingStudentShow from "./BingStudentShow"
  import moment from 'moment'

  export default{
    data:function(){
      return {
        total: 0,
        pageSize: 10,
        pageNo: 1,
        tableData: [],
        checkList: [],
        query:{
          phoneNo:'',
        },
        bingStudentList:[],
        gridData:[],
        dialogTableVisible:false,
      }
    },
    components: {
       Pagination,
       BingStudentShow

    },
    created(){
      this.loadTableData(1)
    },
    mounted :function(){
      $(window).smoothScroll()
    },
    methods:{
      handsearch(){
        this.loadTableData(1)
      },
      loadTableData: function (pageNo) {
        this.pageNo = pageNo || this.pageNo || 1
        this.$showLoading()
        io.post(io.customerUserList, Object.assign({},this.query, {
          pageNo: this.pageNo,
          pageSize: this.pageSize,
        }), (ret) => {
          this.$hiddenLoading()
          if (ret.success) {
            
            this.tableData = ret.data.list
            this.total = ret.data.total
          } else {
            this.$alert(ret.desc)
          }
        })
      },
      handleDelete(){
        var _this = this
        // _this.$confirm('你确定要删除？',
          // function () {
          //   io.post(io.delExamPaper, {
          //     examPaperId: examPaperId,
          //   }, function (ret) {
          //     if (ret.success) {
          //       _this.$toast('删除成功！')
          //       _this.loadTableData()
          //     } else {
          //       _this.$alert(ret.desc)
          //     }
          //   })
          // });
      },
      handleSee(userId){
        this.$refs.bingStudentShow.userId = userId
        this.$refs.bingStudentShow.show()
      }
    }
  }
</script>
<style lang="less" scoped>
</style>
